use sgs_runtime::{
    executor::{Controller, Event, Start, Viewer},
    preclude::Delegate,
};

/// Setup 事件委托器
///
/// 通知启动信息
///
/// 返回 [Start::Begin] 事件
///
/// 该委托器仅用于自定义通知信息
pub struct StdSetupDelegator;

impl std::fmt::Debug for StdSetupDelegator {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "标准包唤醒事件委托器[sgs_pkg_std::StdSetupDelegator]")
    }
}

impl Delegate for StdSetupDelegator {
    fn delegate(
        &self,
        event: &Event,
        viewer: &Viewer,
        _controller: &mut Controller,
    ) -> Option<Event> {
        match event {
            Event::Setup => {
                println!(
                    "{}[{}@{}] 模式[{}]",
                    viewer.pkg_name, viewer.tag, viewer.version, viewer.pattern_name
                );
                Some(Start::Begin.into())
            }
            _ => None,
        }
    }
}
